package com.tuozixuan.factory.method;

public class Client {

	public static void main(String[] args) {

		VehicleFactory carFactory = new CarFactory();
		carFactory.orderVehicle("small", "blue");

		VehicleFactory truckFactory = new TruckFactory();
		truckFactory.orderVehicle("large", "blue");

		// 匿名具体工厂模式
		VehicleFactory bikeFactory = new VehicleFactory() {

			@Override
			protected Vehicle createVehicle(String size) {
				if ("small".equals(size)) {
					return new MountainBike();
				} else if ("large".equals(size)) {
					return new CityBike();
				}
				return null;
			}
		};
		bikeFactory.orderVehicle("large", "blue");
	}

}
